<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use DB;

class GrowController extends Controller
{
  public function run($uid){
    $today = date('Y-m-d');
    $tasks = DB::table('tasks')->where('enddate','>=',$today)->where('uid',$uid)->get();
    foreach($tasks as $t){
      $t = (array) $t;
      $t['paytime'] = $today;
      unset($t['enddate']);
      unset($t['tid']);
      DB::table('grows')->insert($t);
    }
  }

}
